package cn.edu.scau.cmi.zhuangziyuan.hibernate;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class test {

	public static void main(String[] args){
		TeacherDAOByHibernate th=new TeacherDAOByHibernate();
		Teacher ttt=new Teacher();
		String name="zhuang";
		ttt.setName(name);

		th.add(ttt);
		
		
		StudentDAOByHibernate sh=new StudentDAOByHibernate();
		Student sss=new Student();
		String names="zhuangzi";
		sss.setName(names);
		sss.setTutor(ttt);
		sh.add(sss);
		
		Student ssss=new Student();
		ssss.setId(1);
		
		
		
		Student newStudent = sh.selectById(ssss);
		newStudent.setTutor(ttt);
		sh.update(newStudent);
		
		/*
		Teacher t=new Teacher();
		long id=1;
		t.setId(id);
		Teacher tt=th.selectById(t);
		th.delete(tt);*/
		
		List<Teacher> list=th.listAll();
		for(Teacher t:list){
			System.out.println(t);
		}
		
		System.out.println("OK");
		
	}
}
